import cv2
import numpy as np

img_bgr = cv2.imread("img.png")
img_hsv = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2HSV)
img_h, img_s, img_v = cv2.split(img_hsv)
lower_h, upper_h =140, 175
lower_s, upper_s =80, 255
lower_v, upper_v =80, 255
mask_h = cv2.inRange(img_h, lower_h, upper_h)
mask_s = cv2.inRange(img_s, lower_s, upper_s)
mask_v = cv2.inRange(img_v, lower_v, upper_v)
mask_h_and_s = cv2.bitwise_and(mask_h, mask_s)
mask = cv2.bitwise_and(mask_h_and_s, mask_v)
img_out = cv2.bitwise_and(img_bgr, img_bgr, mask=mask)
cv2.imshow("img", img_out)
cv2.imwrite("img_out.png", img_out)
cv2.waitKey(0)